package cn.bytecollege.admin.controller; /**
 * @Auther：MR.P
 * @Date:2021/10/28 16 52
 * @Description:
 */

import cn.bytecollege.admin.service.ClassifyService;
import cn.bytecollege.common.entity.Classify;
import cn.bytecollege.common.entity.Page;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "ClassifyListController", value = "/admin/classifyList")
public class ClassifyListController extends HttpServlet {
    private ClassifyService classifyService = null;
    public ClassifyListController(){
        classifyService = new ClassifyService();
    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String index = request.getParameter("index");
        int pageIndex = (index==null)?1:Integer.parseInt(index);
        String size = request.getParameter("size");
        int pageSize = (size==null)?10:Integer.parseInt(size);
        //获得分页数据
        Page<Classify> page = classifyService.findByPage(pageIndex,pageSize);
        request.setAttribute("page",page);
        request.getRequestDispatcher("/admin/html/device/classifyList.jsp").forward(request,response);
    }
}
